﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PUCIT.eFCS.Business;

namespace PUCIT.eFCS
{
    public partial class DesignStudentSection : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BtnBack.PostBackUrl = (string)Session["page"];
            }

            string FormName = (string)Session["DocumentName"];

            ContentPlaceHolder contentPlaceHolder = new ContentPlaceHolder();
            contentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder2");

            LblFormName.Text = FormName;
        }

        protected void Btn_Click(object sender, EventArgs e)
        {
            string FormName = (string)Session["DocumentName"];
            int seqno = 1;
            string htmltag;
            string label;
            string htmlfieldid;
            int check = 0;

            List<Section> sections = new List<Section>();
            Section Student = new Section();
            List<Field> StdFields = new List<Field>();

            if (Subject.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdSubject name=StdSubject size=59";
                label = "Subject: ";
                htmlfieldid = "StdSubject";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Exp.Checked)
            {
                Field field = new Field();

                htmltag = "<textarea id=StdExplanation name=StdExplanation rows=20 cols=46";
                label = "Explanation: ";
                htmlfieldid = "StdExplanation";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (stdName.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdName name=StdName size=59";
                label = "Name:";
                htmlfieldid = "StdName";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (FatherName.Checked)
            {
                Field field = new Field();
                htmltag = "<input type=text id=StdFatherName name=StdFatherName size=59";
                label = "Father Name:";
                htmlfieldid = "StdFatherName";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (gender.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=radio id=StdGenderRB name=StdGenderRB value=Male checked='true' /> Male&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio id=StdGenderRB name=StdGenderRB value=Female /> Female";
                label = "Gender:";
                htmlfieldid = "StdGenderRB";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Dob.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdDob name=StdDob size=59";
                label = "Date of Birth:";
                htmlfieldid = "StdDob";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;

                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (NIC.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdNIC name=StdNIC size=59";
                label = "NIC#: ";
                htmlfieldid = "StdNIC";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;

                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (BloodGrp.Checked)
            {
                Field field = new Field();

                htmltag = "<select id=StdBloodGroupDDL name=StdBloodGroupDDL title=BloodGroup>" +
                            "<option value='A+'>A+</option>" +
                            "<option value='A-'>A-</option>" +
                            "<option value='B+'>B+</option>" +
                            "<option value='B-'>B-</option>" +
                            "<option value='AB+'>AB+</option>" +
                            "<option value='AB-'>AB-</option>" +
                            "<option value='O+'>O+</option>" +
                            "<option value='O-'>O-</option>" +
                            "</select>";
                label = "BloodGroup:";
                htmlfieldid = "StdBloodGroupDDL";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;

                StdFields.Add(field);
                seqno++;
                check++;

            }
            if (Nationality.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdNationality name=StdNationaltiy size=59";
                label = "Nationality: ";
                htmlfieldid = "StdNationality";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;

                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Phone.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdPhone name=StdPhone size=59";
                label = "Phone#:";
                htmlfieldid = "StdPhone";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;

                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Address.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdAddress name=StdAddress size=59";
                label = "Address:";
                htmlfieldid = "StdAddress";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (District.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdDistrict name=StdDistrict size=59";
                label = "District: ";
                htmlfieldid = "StdDistrict";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (reg.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdRegNo name=StdRegNo size=59";
                label = "P.U Registration#: ";
                htmlfieldid = "StdRegNo";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Rollno.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdRollNo name=StdRollNo size=59";
                label = "RollNo: ";
                htmlfieldid = "StdRollNo";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (CurrSem.Checked)
            {
                Field field = new Field();

                htmltag = "//";
                label = "Current Semester: ";
                htmlfieldid = "StdSemesterDDL";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Cgpa.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=text id=StdCgpa name=StdCgpa size=59";
                label = "CGPA: ";
                htmlfieldid = "StdCgpa";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (Section.Checked)
            {
                Field field = new Field();

                htmltag = "<input type=radio id=StdSectionRB name=StdSectionRB value=Morning checked='true' /> Morning&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=radio id=StdSectionRB name=StdSectionRB value=Afternoon /> Afternoon";
                label = "Section: ";
                htmlfieldid = "StdSectionRB";

                field.FieldLabel = label;
                field.SeqNo = seqno;
                field.FieldHtml = htmltag;
                field.FieldHtmlId = htmlfieldid;
                StdFields.Add(field);
                seqno++;
                check++;
            }
            if (check > 0)
            {
                Student.SectionTitle = "Student Section";
                Student.SectionFields = StdFields;
                Student.SeqNo = 1;
                Student.UserId = 1;

                sections.Add(Student);
                Session["sections"] = sections;
                Response.Redirect("DesignStationSections.aspx");
            }
            else if (check == 0)
            {

                ErrorMsg.Controls.Add(new LiteralControl("Select Atleast One Field"));

            }
        }
    }
}